Skip to content

ht4#48

Open
annakovarskaya wants to merge 3 commits into
romabelka:masterfrom
annakovarskaya:master
Open

ht4#48
annakovarskaya wants to merge 3 commits into
romabelka:masterfrom
annakovarskaya:master

Conversation

@annakovarskaya
Copy link
Copy Markdown

No description provided.

…торе добавляется комент с этим айди, и айди добавляется в список комментов соответствующей статьи в сторе. Пока не разобралась, как обновлять список коментов на странице при обновлении стора.
@@ -0,0 +1,4 @@
export default store => next => action => {
if (action.type === 'ADD_COMMENT') action.payload.id = Math.random().toString(36).substring(7);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

через мидлвары будет проходить каждый экшин, они должны быть максимально общими, завязывать на конкретные экшины - не лучшее решение

  • лучше не мутировать payload, мало-ли что там станут передавать

Comment thread src/reducer/articles.js
switch (type) {
case ADD_COMMENT:
articlesStateObj = articlesState
articlesStateObj[payload.articleId].comments.push(payload.id)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не мутируй стейт!

Comment thread src/reducer/articles.js
case DELETE_ARTICLE:
return articlesState.filter(article => article.id !== payload.id)
articlesStateObj = articlesState
delete articlesStateObj[payload.id]
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

и тут не мутируй

Comment thread src/reducer/comments.js
case ADD_COMMENT:
debugger;
newCommentsState = commentsState
newCommentsState[payload.id] = {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

и тут

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants